import api from '@/api/index.js';
import store from '@/store/index.js';
import {getAuthorArticlesAction}   from "@/store/actions/profilearticleAction.js"
export default async function loader({request,params}) {
    const {username} = params;
    const response = await api.user.get(username);
    if (response && response.status !==1) throw new Error(response.message);
    const author = response.data;

    // 获取作者文章
    store.dispatch(getAuthorArticlesAction(username,1))
    return author;
}